home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Estrategia / coffeetycoon_Demo.swf / scripts / %3Cdefault package%3E / JCPreloaderMC.as < prev   
Encoding:
Text File  |  2006-06-13  |  4.7 KB  |  163 lines

  1. function JCPreloaderClass()
  2. {
  3.    var _loc1_ = this;
  4.    _loc1_.orgWidth = 100;
  5.    _loc1_.orgHeight = 20;
  6.    _loc1_.factor = 0;
  7.    _loc1_.proceedAt = 99;
  8.    _loc1_.spacer = 2;
  9.    _loc1_.init();
  10. }
  11. JCPreloaderClass.prototype = new MovieClip();
  12. JCPreloaderClass.prototype.init = function()
  13. {
  14.    var _loc1_ = this;
  15.    _loc1_.orgWidth = _loc1_._width;
  16.    _loc1_.orgHeight = _loc1_._height;
  17.    _loc1_._xscale = _loc1_._yscale = 100;
  18.    _loc1_.boundingBox_mc._visible = false;
  19.    _loc1_.setSize(_loc1_.orgWidth,_loc1_.orgHeight);
  20.    _loc1_._x = parseInt(_loc1_._x);
  21.    _loc1_._y = parseInt(_loc1_._y);
  22.    _loc1_.txtAttrib = new TextFormat();
  23.    _loc1_.txtAttrib.color = 0;
  24.    _loc1_.txtAttrib.font = "_sans";
  25.    _loc1_.txtAttrib.embedFonts = false;
  26.    _loc1_.txtAttrib.size = _loc1_.orgHeight / 2 + 3;
  27.    _loc1_.txtAttrib.align = "center";
  28.    if(_loc1_.mcToPlay ne "")
  29.    {
  30.       _loc1_.playMC = _loc1_._parent[_loc1_.mcToPlay];
  31.       _loc1_.playMCLength = _loc1_.playMC._totalframes;
  32.    }
  33.    _loc1_.onEnterFrame = function()
  34.    {
  35.       var _loc1_ = this;
  36.       _loc1_.bLoaded = _loc1_._parent.getBytesLoaded();
  37.       _loc1_.bTotal = _loc1_._parent.getBytesTotal();
  38.       _loc1_.factor = Math.ceil(_loc1_.bLoaded / _loc1_.bTotal * 100);
  39.       if(_loc1_.factor < _loc1_.proceedAt)
  40.       {
  41.          var _loc2_ = _loc1_.factor * _loc1_.playMCLength / 100;
  42.          _loc1_.playMC.gotoAndStop(_loc2_);
  43.          _loc1_._parent.stop();
  44.       }
  45.       else if(!_loc1_.thisIsThepreview)
  46.       {
  47.          _loc1_._parent.play();
  48.       }
  49.       _loc1_.redraw();
  50.       if(_loc1_.thisIsThepreview)
  51.       {
  52.          _loc1_.onEnterFrame = null;
  53.       }
  54.    };
  55. };
  56. JCPreloaderClass.prototype.setSize = function(w, h)
  57. {
  58.    var _loc1_ = this;
  59.    _loc1_.orgWidth = w;
  60.    _loc1_.orgHeight = h;
  61.    _loc1_.boundingBox_mc._width = w;
  62.    _loc1_.boundingBox_mc._height = h;
  63.    _loc1_.redraw();
  64. };
  65. JCPreloaderClass.prototype.redraw = function()
  66. {
  67.    var _loc1_ = this;
  68.    _loc1_.setText();
  69.    _loc1_.clear();
  70.    if(_loc1_.showBar)
  71.    {
  72.       var _loc3_ = _loc1_.factor * _loc1_.orgWidth / 100;
  73.       var _loc2_ = _loc1_.orgHeight;
  74.       var w2 = _loc1_.orgWidth;
  75.       _loc1_.drawRectangle(_loc1_.sp * -1,_loc1_.orgWidth + _loc1_.sp,_loc1_.sp * -1,_loc1_.orgHeight + _loc1_.sp,_loc1_.color5,_loc1_.color5,100,false);
  76.       if(_loc1_.factor > 0)
  77.       {
  78.          _loc1_.drawRectangle(0,_loc3_,0,_loc2_,_loc1_.color1,_loc1_.color2,100,true);
  79.       }
  80.       if(_loc1_.factor < 100)
  81.       {
  82.          _loc1_.drawRectangle(_loc3_,w2,0,_loc2_,_loc1_.color3,_loc1_.color4,100,true);
  83.       }
  84.    }
  85. };
  86. JCPreloaderClass.prototype.setText = function()
  87. {
  88.    var _loc1_ = this;
  89.    if(_loc1_.thisIsThepreview)
  90.    {
  91.       _loc1_.factor = random(100);
  92.    }
  93.    if(_loc1_.showText)
  94.    {
  95.       if(_loc1_.factor < _loc1_.proceedAt)
  96.       {
  97.          _loc1_.percentloaded = _loc1_.factor + "% loaded";
  98.       }
  99.       else
  100.       {
  101.          _loc1_.percentloaded = "Loading complete!";
  102.       }
  103.    }
  104.    else
  105.    {
  106.       _loc1_.percentloaded = "";
  107.    }
  108.    _loc1_.fontSize = _loc1_.orgHeight / 2 + 3;
  109.    _loc1_.txtAttrib.size = _loc1_.fontSize;
  110.    _loc1_.yOffsetText = _loc1_.orgHeight / 2 - _loc1_.fontSize / 2 - 2;
  111.    _loc1_.createTextField("percentTxt",9,0,_loc1_.yOffsetText,_loc1_.orgWidth,_loc1_.orgHeight + 3);
  112.    _loc1_.percentTxt.setNewTextFormat(_loc1_.txtAttrib);
  113.    _loc1_.percentTxt.text = _loc1_.percentloaded;
  114.    _loc1_.percentTxt.selectable = false;
  115. };
  116. JCPreloaderClass.prototype.drawRectangle = function(x1, x2, y1, y2, lineCol, fillCol, trans, shallWeFill)
  117. {
  118.    var _loc1_ = this;
  119.    var _loc2_ = y1;
  120.    var _loc3_ = x1;
  121.    _loc1_.lineStyle(_loc1_.lineWidth,lineCol);
  122.    if(shallWeFill)
  123.    {
  124.       _loc1_.beginFill(fillCol,trans);
  125.    }
  126.    _loc1_.moveTo(_loc3_,_loc2_);
  127.    _loc1_.lineTo(x2,_loc2_);
  128.    _loc1_.lineTo(x2,y2);
  129.    _loc1_.lineTo(_loc3_,y2);
  130.    _loc1_.lineTo(_loc3_,_loc2_);
  131.    if(shallWeFill)
  132.    {
  133.       _loc1_.endFill();
  134.    }
  135. };
  136. JCPreloaderClass.prototype.getLabel = function()
  137. {
  138.    return this.fLabel_mc.labelField.text;
  139. };
  140. JCPreloaderClass.prototype.setLabel = function(label)
  141. {
  142.    var _loc1_ = this;
  143.    _loc1_.fLabel_mc.setLabel(label);
  144.    _loc1_.txtFormat();
  145.    _loc1_.arrangeLabel();
  146.    if(Accessibility.isActive())
  147.    {
  148.       Accessibility.sendEvent(_loc1_,0,_loc1_.EVENT_OBJECT_NAMECHANGE);
  149.    }
  150. };
  151. JCPreloaderClass.prototype.setClickHandler = function(chng, obj)
  152. {
  153.    var _loc1_ = this;
  154.    _loc1_.handlerObj = arguments.length >= 2 ? obj : _loc1_._parent;
  155.    _loc1_.clickHandler = chng;
  156. };
  157. JCPreloaderClass.prototype.executeCallBack = function()
  158. {
  159.    var _loc1_ = this;
  160.    _loc1_.handlerObj[_loc1_.clickHandler](_loc1_);
  161. };
  162. Object.registerClass("JCPreloaderMC",JCPreloaderClass);
  163.